<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Course;
use App\Models\Hire;
use App\Models\Information;
use App\Models\Live;
use App\Models\Node;
use App\Models\Post;
use App\Models\Product;
use Illuminate\Http\Request;

class IndexController extends Controller
{


    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $data = [];
        $data['Course'] = Course::skip(1)->take(12)->orderBy('created_at','desc')->get();
        $data['Live'] = Live::skip(1)->take(6)->orderBy('created_at','desc')->get();
        $data['Information'] = Information::skip(1)->take(10)->orderBy('created_at','desc')->get();
        $data['Post'] = Post::skip(1)->take(10)->orderBy('created_at','desc')->get();
        $data['Product'] = Product::skip(1)->take(12)->orderBy('created_at','desc')->get();
        $data['Node'] = Node::skip(1)->take(12)->orderBy('created_at','desc')->get();
        $data['Hire'] = Hire::skip(0)->take(5)->orderBy('created_at','desc')->get();

        return response()->json(['code' => 200, 'message' => '操作成功','data'=>$data]);
    }
}
